TARGET=atmega8
ISP=usbasp
F_CPU=16000000

COMPILE = avr-gcc -Wall -lm -I. -O2 -mmcu=$(TARGET) -DF_CPU=$(F_CPU) # -DDEBUG_LEVEL=2
ARCHIVE = avr-ar rcs
OBJCOPY = avr-objcopy -O ihex
OBJECTS = main.o usart.o adc.o

.c.o:
	$(COMPILE) -c $< -o $@

main.hex: $(OBJECTS)
	$(COMPILE) -O2 -o $(PROG).elf $(OBJECTS)
	$(OBJCOPY) $(PROG).elf $(PROG).hex

clean:
	rm -f *.o *.elf *.hex

flash:
	avrdude -c ${ISP} -p ${TARGET} -U flash:w:$(PROG).hex
